<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <h1>第一题</h1>
    <button id="aa">打开窗口</button><br>
    <button id="bb">document.write</button><span>先清空，在写入</span><br>
    <input type="text" id="cc"><button id="dd">运行代码框</button>
    <h1>第二题</h1>
    <textarea name="" id="" cols="30" rows="10">
        &lt;button class="btn btn-info" onclick="window.close()"&gt;关闭窗口&lt;/button&gt;
    </textarea>
    <button id="gg">运行代码框</button>
    <h1>第三题</h1>
    <button id="ii">查看当前浏览器信息</button>
    <button id="ll">查看当前网址</button>
    <button id="pp">赋值百度为当前网址</button>
</body>
<script>
    window.onload = function () {
        let aa = document.getElementById('aa');
        let bb = document.getElementById('bb');
        let dd = document.getElementById('dd');
        let gg = document.getElementById('gg');
        let ii = document.getElementById('ii');
        let ll = document.getElementById('ll');
        let pp = document.getElementById('pp');
        aa.onclick = function () {
            window.open('http://www.mhero.com/', '_blank');
        }
        bb.onclick = function () {
            document.write('先清空后输入')
        }
        dd.onclick = function () {
            let cc = document.getElementById('cc').value;
            let ff = window.open();
            ff.document.write(cc)
            // console.log(ff)
        }

        // 第二题
        gg.onclick = function(){
            let textarea = document.getElementsByTagName('textarea')[0];
            let hh = window.open();
            hh.document.write(textarea.value);
            
            console.log(textarea.value)
        }

        // 第三题
        ii.onclick = function(){
            alert(window.navigator.userAgent)
        }
        ll.onclick = function(){
            alert(window.location.href)
            // console.log(window.location.href)
        }
        pp.onclick = function(){
            window.location.href = "https://www.baidu.com/"
        }
    }
</script>

</html>